﻿using System.ComponentModel;
using System.Windows.Controls;
using Notoric.Commanding.CommandBase;
using System;

namespace Notoric.Gui
{
    /// <summary>
    /// Holds the current application state.
    /// </summary>
    public class ApplicationState : INotifyPropertyChanged, View.Music.CWNotation.IApplicationState
    {
        #region INotifyPropertyChanged Members

        /// <inheritdoc/>
        public event PropertyChangedEventHandler PropertyChanged;

        #endregion

        #region Public Properties

        /// <summary>
        /// Gets or sets the command that should be executed when the user finishes the mouse action.
        /// </summary>
        /// <value>
        /// <para>
        /// Type: <see cref="CommandBase"/>
        /// </para>
        /// <para>
        /// The command that should be executed when the user finishes the mouse action.<br/>
        /// If this value is <see langword="null"/> the action is left to the control that
        /// receives the input.
        /// </para>
        /// </value>
        public CommandBase Command
        {
            get { return command; }
            set
            {
                command = value;

                if (PropertyChanged != null)
                    PropertyChanged(this, new PropertyChangedEventArgs("Command"));
            }
        }

        /// <summary>
        /// Gets or sets the application part that is currently the target of the mouse action.
        /// </summary>
        /// <value>
        /// <para>
        /// Type: <see cref="Type"/>
        /// </para>
        /// <para>
        /// The application part that is currently meant to be a target of a user action.
        /// This part alone should receive mouse input, all the other parts
        /// should disable them selves or refuse the mouse input.<br/>
        /// If this value is <see langword="null"/> the whole application area is mouse enabled.
        /// </para>
        /// <para>
        /// This property is used for example when the user wants to insert a new
        /// section to a page. He has to first draw the area where he wants
        /// to put the new section. The only part that should now receive
        /// the mouse input is the page.
        /// </para>
        /// </value>
        public Type MouseTarget
        {
            get { return mouseTarget; }
            set
            {
                mouseTarget = value;

                if (PropertyChanged != null)
                    PropertyChanged(this, new PropertyChangedEventArgs("MouseTarget"));
            }
        }

        /// <summary>
        /// Gets or sets the status bar message.
        /// </summary>
        /// <value>
        /// <para>
        /// Type: <see cref="string"/>
        /// </para>
        /// <para>
        /// An optional message for the user displayed in the application status bar.
        /// </para>
        /// </value>
        public string StatusBarMessage
        {
            get { return statusBarMessage; }
            set
            {
                statusBarMessage = value;

                if (PropertyChanged != null)
                    PropertyChanged(this, new PropertyChangedEventArgs("StatusBarMessage"));
            }
        }

        #endregion

        #region Private Fields

        /// <summary>
        /// Holds the value of the <see cref="Command"/> property.
        /// </summary>
        private CommandBase command;
        /// <summary>
        /// Holds the value of the <see cref="MouseTarget"/> property.
        /// </summary>
        private Type mouseTarget;
        /// <summary>
        /// Holds the value of the <see cref="StatusBarMessage"/> property.
        /// </summary>
        private string statusBarMessage;

        #endregion
    }
}
